
#ifndef __MODEL_EDITOR_H
#define __MODEL_EDITOR_H

#include <d3d9.h>
#include <d3dx9.h>

#include "OyEngineHeader\OyGeneral.h"		// Commom Lib
#include "OyEngineHeader\OyMath3D.h"		// Math Lib
#include "OyEngineHeader\OyRenderer.h"		// our render interface

#include "../JuceLibraryCode/JuceHeader.h"

class CModelEditorConfig
{
public:
	struct UILayout
	{
		bool bShowLeftPanel;
		bool bShowRightPanel;
		bool bShowBottomPanel;

		UILayout()
		{
			bShowLeftPanel = bShowRightPanel = bShowBottomPanel = true;
		}
	};

	struct UIResDirFileFilter
	{
		bool bShowMD2;
		bool bShowMD3;
		bool bShowMS3D;
		bool bShowBTM1;
		bool bShowPicture;


		bool bEnableHardDiskVolume[10];

	};

	inline static CModelEditorConfig* GetInstance()
	{
		static CModelEditorConfig staticInstance;
		return &staticInstance;
	}

	CModelEditorConfig() : m_bFrame0Render(1), 
		m_fFrames_per_second(16.0f), m_UIStartFrameID(0), m_UIEndFrameID(0),
		m_fAnimPlayingSpeed(1.0f), m_UIStartTime(0.0f), m_UIEndTime(0.0f)
	{ 
		ResetDefaultColor();
		ResetUIResDirFilter();
	}

	~CModelEditorConfig() {}

	void CloseScene();

	void ResetUIResDirFilter()
	{
		m_ResDirFileFilter.bShowMD2 = true;
		m_ResDirFileFilter.bShowMD3 = false;
		m_ResDirFileFilter.bShowMS3D = false;
		m_ResDirFileFilter.bShowBTM1 = false;
		m_ResDirFileFilter.bShowPicture = false;


		memset(m_ResDirFileFilter.bEnableHardDiskVolume, 0, sizeof(bool) * 10);


		File temp_volume_file_c("c:");
		if( temp_volume_file_c.exists() )
			m_ResDirFileFilter.bEnableHardDiskVolume[0] = true;
		File temp_volume_file_d("d:");
		if( temp_volume_file_d.exists() )
			m_ResDirFileFilter.bEnableHardDiskVolume[1] = true;
		File temp_volume_file_e("e:");
		if( temp_volume_file_e.exists() )
			m_ResDirFileFilter.bEnableHardDiskVolume[2] = true;
		File temp_volume_file_f("f:");
		if( temp_volume_file_f.exists() )
			m_ResDirFileFilter.bEnableHardDiskVolume[3] = true;
	}

	void ResetDefaultColor()
	{
		m_EditorBKColor = Colours::grey;
		m_DefaultColor[0] = Colours::blue;
		m_DefaultColor[1] = Colours::grey;
		m_DefaultColor[2] = Colours::red;
		m_DefaultColor[3] = Colours::yellow;
		m_DefaultColor[4] = Colours::aliceblue;
		m_DefaultColor[5] = Colours::antiquewhite;
		m_DefaultColor[6] = Colours::aqua;
		m_DefaultColor[7] = Colours::aquamarine;
		m_DefaultColor[8]  = Colours::azure;
		m_DefaultColor[9]  = Colours::beige;
		m_DefaultColor[10] = Colours::bisque;
		m_DefaultColor[11] = Colours::blanchedalmond;
		m_DefaultColor[12] = Colours::blueviolet;
		m_DefaultColor[13] = Colours::brown;
		m_DefaultColor[14] = Colours::burlywood;
		m_DefaultColor[15] = Colours::cadetblue;
		m_DefaultColor[16]  = Colours::chartreuse;
		m_DefaultColor[17]  = Colours::chocolate;
		m_DefaultColor[18] = Colours::coral;
		m_DefaultColor[19] = Colours::cornflowerblue;
		m_DefaultColor[20] = Colours::cornsilk;
		m_DefaultColor[21] = Colours::crimson;
		m_DefaultColor[22] = Colours::cyan;
		m_DefaultColor[23] = Colours::darkblue;
	}
public:
	static Colour					m_EditorBKColor;
	static Colour					m_DefaultColor[24];
	static UILayout					m_UILayout;
	static UIResDirFileFilter		m_ResDirFileFilter;


	juce::Atomic< unsigned int >	m_bFrame0Render;

	// MD2 file UI Setting
	juce::Atomic< float >			m_fFrames_per_second;
	static int						m_CurrentFrameID;
	static UINT						m_CurrentAnimID;
	static bool						m_bLoopPlayMode;
	juce::Atomic< unsigned int >	m_UIStartFrameID;
	juce::Atomic< unsigned int >	m_UIEndFrameID;
	
	// Ms3d file UI Setting
	juce::Atomic< float >			m_fAnimPlayingSpeed;
	juce::Atomic< float >			m_UIStartTime;
	juce::Atomic< float >			m_UIEndTime;
	static float					m_CurrentAnimTime;
};


extern LPOYRENDERER				g_pRenderer;
extern LPOYRENDERDEVICE			g_pDevice;
extern OyTimer*					g_pTimer;
extern float					g_Aspect;
extern OY_UCOLOR_VERTEX_TYPE*	g_GuidVertex;
extern OY_UCOLOR_VERTEX_TYPE*	g_AxisVertex;


extern UINT						g_DefaultSkin;



class CModel;
extern CModel*					g_pCurrentModelFile;

#endif